package cn.iocoder.yudao.module.crm.dal.mysql.coursematerial;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.crm.controller.admin.course.vo.CourseMaterialPageReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.course.CourseDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.coursematerial.CourseMaterialDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 课程课件 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface CourseMaterialMapper extends BaseMapperX<CourseMaterialDO> {

    default PageResult<CourseMaterialDO> selectPage(CourseMaterialPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CourseMaterialDO>()
                .eqIfPresent(CourseMaterialDO::getIcon, reqVO.getIcon())
                .eqIfPresent(CourseMaterialDO::getSort, reqVO.getSort())
                .eqIfPresent(CourseMaterialDO::getMaterialType, reqVO.getMaterialType())
                .eqIfPresent(CourseMaterialDO::getMaterialUrl, reqVO.getMaterialUrl())
                .eqIfPresent(CourseMaterialDO::getMaterialDuration, reqVO.getMaterialDuration())
                .eqIfPresent(CourseMaterialDO::getStatus, reqVO.getStatus())
                .eqIfPresent(CourseMaterialDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(CourseMaterialDO::getCreateTime, reqVO.getCreateTime())
                .in(reqVO.getInCourseMaterialIds()!=null&&!reqVO.getInCourseMaterialIds().isEmpty(), CourseMaterialDO::getId,reqVO.getInCourseMaterialIds())
                .notIn(reqVO.getNotInCourseMaterialIds()!=null&&!reqVO.getNotInCourseMaterialIds().isEmpty(),CourseMaterialDO::getId,reqVO.getNotInCourseMaterialIds())
                .orderByDesc(CourseMaterialDO::getId));
    }

}